<template>
  <div>
    <h1>第二题</h1>
    <div>
      <ul>
        <li v-for="(item, index) in arr" :key="index">
          <span>{{ item }}</span>
          <button @click.prevent="del(index)">删除</button>
        </li>
      </ul>
      <button @click.prevent="add">生成</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1, 3, 5],
    }
  },
  methods: {
    add() {
      // console.log(Math.floor(Math.random() * 10))
      this.arr.push(Math.floor(Math.random() * 10))
    },
    del(index) {
      this.arr.splice(index, 1)
    },
  },
}
</script>

<style></style>
